package pl.edu.mimuw.irs.rcp.view.navigation;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

public class TreeParent extends TreeObject {
	private List<TreeObject> children;
	public TreeParent(String name) {
		super(name);
		children = new ArrayList<TreeObject>();
	}
	public void addChild(TreeObject child) {
		children.add(child);
		child.setParent(this);
	}
	public void removeChild(TreeObject child) {
		children.remove(child);
		child.setParent(null);
	}
	public TreeObject[] getChildren() {
		return children.toArray(new TreeObject[children.size()]);
	}
	public boolean hasChildren() {
		return children.size() > 0;
	}
	public Image getIcon() {
		String imageKey = ISharedImages.IMG_OBJ_FOLDER;
		return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
	}
}
